package cn.itrip.itripbiz;

import cn.itrip.common.SystemConfig;
import cn.itrip.common.ValidationToken;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.data.redis.core.StringRedisTemplate;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
@MapperScan("cn.itrip.dao")
@PropertySource("systemConfig.properties")

public class ItripBizApplication {
	@Autowired
    private Environment env;
	@Bean
	public SystemConfig systemConfig(){
		SystemConfig systemConfig = new SystemConfig();
		//set
		systemConfig.setFileUploadPathString(env.getProperty("sysConfig.fileUploadPath"));
		systemConfig.setVisitImgUrlString(env.getProperty("sysConfig.visitImgUrl"));
		systemConfig.setMachineCode(env.getProperty("sysConfig.machineCode"));
		systemConfig.setOrderProcessOK(env.getProperty("sysConfig.orderProcessOK"));
		systemConfig.setOrderProcessCancel(env.getProperty("sysConfig.orderProcessCancel"));
		return systemConfig;
	}

	@Bean
	public ValidationToken validationToken(StringRedisTemplate stringRedisTemplate){
		ValidationToken validationToken = new ValidationToken();
		validationToken.setRedisAPI(stringRedisTemplate);
		return validationToken;
	}

	public static void main(String[] args) {
		SpringApplication.run(ItripBizApplication.class, args);
	}

}
